<template>
    <div class="bigbox">
       <div class="goodsitem" v-for="item in goodsList" :key="item.id" @click="getGoodsInfo(item.id)">
            <img :src="item.img_url" alt="">
        <h1>{{item.title}}</h1>
        <div class="top-box">
            <p>
                <span class="now">
                    ￥{{item.sell_price}}
                </span>
                <span class="old">
                    ￥{{item.market_price}}
                </span>
            </p>
            <div class="bottom">
                <span>热卖中</span>
                <span>剩余{{item.stock_quantity}}件</span>
                
            </div>
        </div>
       </div>
       <mt-button type='danger' size='large' @click="getmore">加载更多</mt-button>
      
     
    </div>
</template>
<script>
export default {
   data() {
       return {
           pageindex:1,
           goodsList:[]
       }
   },
   created() {
       this.getgoodsList()
   },
   methods: {
       getgoodsList(){
           this.$http.get('http://www.liulongbin.top:3005/api/getgoods?pageindex='+this.pageindex).then(result=>{
               if(result.body.status==0){
                   this.goodsList=this.goodsList.concat(result.body.message)
               }
           })
       },
       getmore(){
           this.pageindex++,
           this.getgoodsList()
       },
         getGoodsInfo(id){
            //  导航式路由的第一种方式
       this.$router.push('/home/goodsInfo/'+id)
    //    第二种this.$router.push({ path: 'home' })
   }
   },
 
}
</script>
<style lang="scss" scoped>
.bigbox{
    display: flex;
    flex-wrap: wrap;
    padding: 7px;
    padding: 3px;
    justify-content: space-between;

    .goodsitem{
        // min-height: 

        width: 49%;
        border: 1px solid #ccc;
        box-shadow: 0 0 8px #ccc;
        margin: 3px 0;
        display: flex;
        flex-direction: column;
        justify-content:space-between;
        min-height: 293px;
        img{
            width: 100%;
        }
        h1{
            font-size: 15px;
            color: #26A2FF
        }
        .top-box{
            background-color: #eeeeee;
            .now{
                color: red;
                font-weight: 600;
                font-size: 14px;
            }
            .old{
                margin-left: 10px;
                text-decoration: line-through;
                font-size: 13px;
            }
            .bottom{
                display: flex;
                justify-content: space-between;
                font-size: 13px;
                color: #8f8f94
            }
        }
    }
}
</style>
